<template>
  <div>
    <h2>Child Component</h2>
    <Field name="childField" :component="[Input]" />
    <button @click="updateFormData">Update Form Data from Child</button>
  </div>
</template>

<script setup>
import { Input } from 'ant-design-vue';
import { Field, useForm } from '@formily/vue';

// 获取表单实例
const form = useForm();

// 更新表单数据的方法
const updateFormData = () => {
  console.log('Form instance:', form.value);
  if (form.value) {
    form.value.setFieldValue('childField', 'Updated value from child');
  }
};
</script>

